package com.tuananh.radnom.model.userinfo;

import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

import com.tuananh.radnom.model.netservice.MyMapTypeAdapter;

@XmlRootElement(name="group")
public class UserGroup {
	String name;
	ArrayList<User> users;
	@XmlAttribute
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@XmlJavaTypeAdapter(UserGroupXmlAdapter.class)
	@XmlValue
	public ArrayList<User> getUsers() {
		return users;
	}

	public void setUsers(ArrayList<User> users) {
		this.users = users;
	}

	public static UserGroup getFromName(ArrayList<UserGroup> group, String name) {
		if (group != null && name != null)
			for (UserGroup gr : group) {
				if (gr.getName().equals(name))
					return gr;
			}
		return null;
	}
}
